#pragma once
//#include"encoderAcc.h"
//#include"encoderH264.h"
#include"bus.h"
#include<iostream>
class complexMp4
{
public:
	complexMp4(const std::string& outfile);
	~complexMp4();
public:
	int init_output_formatcontext();

	int addStream(AVCodecContext* codecContext);

	int delete_output_formatcontext();

	int open_mp4_file();
	int write_mp4_header();
	int write_mp4_avpaket(AVPacket* packet);
	int write_mp4_trailer();

	int send_pakcet();

	int getAudioStreamIndex() {	return m_audiostIndex;}
	int getVideoStreamIndex() { return m_videostIndex;}

private:
	uint32_t		  m_audiostIndex;
	uint32_t		  m_videostIndex;
	AVStream*		  m_audioStream;
	AVStream*		  m_videoStream;
	AVCodecContext*   m_audioContext;
	AVCodecContext*   m_videoContext;
	

	AVFormatContext*  m_fmt;
	std::string m_outfile;
};

